<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Auswahllisten</title>
<script type="text/javascript">
	function ausgabe(auswahl) {
		var text = "Index: ";
		text += auswahl.selectedIndex;
		text += "\n";
		text += auswahl[auswahl.selectedIndex].text;
		alert(text);
	}

	function ausgabe2(auswahl) {
		var text = "";
		for ( var i = 0; i < auswahl.length; i++) {
			if (auswahl[i].selected) {
				text += "Index: ";
				text += i;
				text += "\n";
				text += "Text: " + auswahl[i].text + "\n";
			}
		}
		alert(text);
	}
</script>
</head>
<body>
	<form>
		<select id="liste" name="liste" size="5">
			<!-- attribut: size -->
			<option selected="selected">Option 1</option>
			<option>Option 2</option>
			<option>Option 3</option>
			<option>Option 4</option>
			<option>Option 5</option>
			<option>Option 6</option>
		</select> <input type="button" value="Wert anzeigen"
			onclick="ausgabe(this.form.liste)" />
	</form>
	<br />

	<form>
		<select id="liste2" name="liste2" size="4" multiple="multiple">

			<!-- attribut: size -->
			<option>Option 1</option>
			<option>Option 2</option>
			<optgroup label="Gruppe 1">
				<option>Option 3</option>
				<option>Option 4</option>
			</optgroup>
			<option>Option 5</option>
			<option>Option 6</option>
		</select> <input type="button" value="Wert anzeigen"
			onclick="ausgabe2(this.form.liste2)" />
	</form>
</body>
</html>